package com.iceengine.input.keyboard;

/**
 * The KeyboardManager class manages the keyboardlistener and keyboardevents.
 * @author penguin
 */

public class KeyboardManager {
    private KeyboardListener theListener;
    private Thread ListenerThread;

    /**
     * Starts the keyboardlistener.
     */
    public void startListener()
    {
        theListener = new KeyboardListener();
        ListenerThread = new Thread(theListener);
        ListenerThread.setName("Keyboard Listener Thread");
        ListenerThread.start();
    }
    /**
     * Stops the keyboard listener.
     */
    public void stopListener()
    {
        theListener.killThread();
        ListenerThread.stop();
    }
    /**
     * Adds an event to the keyboardlistener.
     * @param toAdd Event to add.
     */
    public void addEvent(IKeyboardEvent toAdd)
    {
        theListener.addEvent(toAdd);
    }
    /**
     * Removes an event from the keyboardlistener.
     * @param toRemove Event to remove.
     */
    public void removeEvent(IKeyboardEvent toRemove)
    {
        theListener.removeEvent(toRemove);
    }
}
